//
//  HBGetDistillRecordParser.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/14.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBGetDistillRecordParser.h"
#import "HBGetDistillRecordInfo.h"
#import "HBGetDistillRecordMonthInfo.h"
#import "HBGetDistillRecordItemInfo.h"

@implementation HBGetDistillRecordParser

-(ParserResult*)parseResponseDictionary:(NSDictionary *)responseDictionary
{
    LLog(@"responseDictionary:%@",responseDictionary);
    ParserResult* result=[[ParserResult alloc]init];
    NSNumber* codeObject=[responseDictionary objectForKey:Key_Code];
    if (codeObject)
    {
        NSInteger code = [codeObject integerValue];
        result.code = code;
        result.message = [responseDictionary objectForKey:Key_Msg];
        if (code == 0)
        {
            HBGetDistillRecordInfo *info = [[HBGetDistillRecordInfo alloc]init];
            NSArray *dataArray = [responseDictionary objectForKey:Key_Data];
            if (dataArray&&[dataArray isKindOfClass:[NSArray class]])
            {
                NSMutableArray *dataMulArray = [NSMutableArray arrayWithCapacity:dataArray.count];
                for (NSDictionary *dict in dataArray)
                {
                    HBGetDistillRecordMonthInfo *listInfo = [[HBGetDistillRecordMonthInfo alloc]init];
                    listInfo.distillMonth = [DataTypeTranslate numberToString:dict[Key_investMonth]];
                    NSArray *subDataAry = dict[Key_distillList];
                    if (subDataAry&&[subDataAry isKindOfClass:[NSArray class]])
                    {
                        NSMutableArray *subDataMulArray = [NSMutableArray arrayWithCapacity:subDataAry.count];
                        for (NSDictionary *subDict in subDataAry)
                        {
                            HBGetDistillRecordItemInfo *listItemInfo = [[HBGetDistillRecordItemInfo alloc]init];
                            listItemInfo.bankCode = [DataTypeTranslate numberToString:subDict[Key_bankCode]];
                            listItemInfo.bankName = [DataTypeTranslate numberToString:subDict[Key_bankName]];
                            listItemInfo.bankCardno = [DataTypeTranslate numberToString:subDict[Key_bankCardno]];
                            listItemInfo.distillMoney = [DataTypeTranslate numberToString:subDict[Key_distillMoney]];
                            listItemInfo.distillTime = [DataTypeTranslate numberToString:subDict[Key_distillTime]];
                            listItemInfo.distillStatus = [DataTypeTranslate numberToString:subDict[Key_distillStatus]];
                            listItemInfo.distillNote = [DataTypeTranslate stringToString:subDict[Key_distillNote]];
                            [subDataMulArray addObject:listItemInfo];
                        }
                        listInfo.distillList = subDataMulArray;
                    }
                    else
                    {
                        listInfo.distillList = [NSArray array];
                    }
                    
                    [dataMulArray addObject:listInfo];
                }
                info.dataAry = dataMulArray;
            }
            else
            {
                info.dataAry = [NSArray array];
            }
            
            result.result = info;
        }
        
    }
    else
    {
        result.code=1;
        result.message=@"服务器数据异常";
    }
    
    return result;
}


@end
